﻿<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="index.css">
</head>

<body>
  <!--版心  -->
  <div class="w">
    <!-- 左侧 -->
    <div class="leftBox">
      <!-- 上 -->
      <div class="top">
        <img src="img/m1.jpg">
      </div>
      <ul>
        <li class="active">
          <img src="img/s1.jpg" msrc="m1.jpg" bsrc="b1.jpg">
        </li>
        <li>
          <img src="img/s2.jpg" msrc="m2.jpg" bsrc="b2.jpg">
        </li>
        <li>
          <img src="img/s3.jpg" msrc="m3.jpg" bsrc="b3.jpg">
        </li>
      </ul>
    </div>
    <!-- 右侧 -->
    <div class="rightBox">
      <img src="img/b1.jpg" alt="">
    </div>
  </div>
  <script src="lib/jquery-1.12.4.js"></script>
  <script>
    $("img").click(function () {
      var asrc = $(this).attr("msrc");
      var bsrc = $(this).attr("bsrc");


      $(this)
      .parent()
      .siblings().removeClass("active");
      console.log( $(this).parent().siblings());



      $(this).parent().addClass("active");
      console.log(asrc);
      $(".top").children().attr("src","img/"+asrc)
      $(".rightBox").children().attr("src","img/"+bsrc)
    })
  </script>
</body>

</html>